package org.dromara.setting.listener;

import lombok.extern.slf4j.Slf4j;
import org.dromara.common.tenant.event.AddTenantEvent;
import org.dromara.setting.init.InitSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 租户监听
 *
 * @author heyi
 * 2024/8/10
 */
@Slf4j
@Component
public class AddTenantListener {

    @Autowired
    private InitSettingService initSettingService;

    /**
     * 监听新建租户事件
     *
     * @param addTenantEvent
     */
    @EventListener
    public void addTenantEvent(AddTenantEvent addTenantEvent) {
        // 初始化某个租户配置
        initSettingService.initSetting(addTenantEvent.getTenantId());
    }
}
